//
//  NSString+HeightLabel.m
//  ProjectA
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "NSString+HeightLabel.h"
#import <UIImageView+WebCache.h>
@implementation NSString (HeightLabel)


+ (CGFloat)heightForImageSetHeight:(CGFloat)setHeight setWidth:(CGFloat)setWidth getWidth:(CGFloat)getWidth {
    
    
    return getWidth / setWidth * setHeight;
}

+ (CGFloat)heightForLabel:(NSString *)text withWidth:(CGFloat)floatNumber withEdge:(CGFloat)edge withFontOfSize:(CGFloat)size {
    if ([text isEqualToString:@""]) {
        //NSLog(@"你输入的字符串是空字符串");
        return 0;
    } else {
        
        CGRect rect = [text boundingRectWithSize:CGSizeMake(floatNumber - (edge * 2), 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:size]} context:nil];
        return rect.size.height;
        
    }
    
}


+ (CGFloat)heightForImage:(UIImage *)image withWidth:(CGFloat)width {
    
    return image.size.height * width / image.size.width;
}


+ (CGFloat)heightForImageUrl:(NSString *)url withWidth:(CGFloat)width {
    
    UIImageView *imageView = [[UIImageView alloc] init];
    [imageView sd_setImageWithURL:[NSURL URLWithString:url]];
    
    return imageView.image.size.height * width / imageView.image.size.width;
}


@end
